local wudao = fk.CreateSkill {

  name = "joy__wudao",

  tags = {  },

}



wudao:addEffect(fk.CardUsing, {
  name = "joy__wudao",
  anim_type = "offensive",
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(wudao.name) and data.card.type ~= Card.TypeEquip then
      local mark = player:getTableMark( "@joy__wudao-turn")
      if table.contains(mark, data.card:getTypeString().."_char") then
        return data.card.sub_type ~= Card.SubtypeDelayedTrick
      else
        local use_e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
        if not use_e then return false end
        local events = player.room.logic.event_recorder[GameEvent.UseCard] or Util.DummyTable
        for i = #events, 1, -1 do
          local e = events[i]
          local use = e.data
          if use.from == player then
            if e.id < use_e.id then
              return use.card.type == data.card.type
            end
          end
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return table.contains(player:getTableMark( "@joy__wudao-turn"), data.card:getTypeString().."_char") or
    player.room:askForSkillInvoke(player, wudao.name, nil, "#joy__wudao-invoke:::"..data.card:getTypeString())
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark( "@joy__wudao-turn")
    local type_name = data.card:getTypeString().."_char"
    if table.contains(mark, type_name) then
      data.disresponsiveList = table.map(room.alive_players, Util.IdMapper)
      if data.card.is_damage_card then
        data.additionalDamage = (data.additionalDamage or 0) + 1
      end
    else
      table.insert(mark, type_name)
      room:setPlayerMark(player, "@joy__wudao-turn", mark)
    end
  end,
})

return wudao